from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCD_DRG

def group(record):
  adrg_zd=["C12.x00x002","C32.900","D10.100","D10.300x005","D10.303","D10.500x001","D10.503","D10.600","D10.603","D10.700","D10.701","D10.900","D14.000x007","D14.000x010","D14.100","D14.101","D14.102","D18.000x504","D18.000x507","D18.000x510","D36.703","D38.001","G47.300x001","G47.300x037","G47.301","J03.900","J03.901","J04.000","J05.100","J33.001","J34.200","J35.000","J35.803","J35.805","J36.x00","J36.x00x001","J36.x00x003","J37.000","J37.001","J38.002","J38.101","J38.102","J38.200","J38.301","J38.304","J38.308","J38.309","J38.312","J38.401","J38.601","J38.705","J38.707","J38.708","J38.712","J38.715","J39.003","J39.200x016","J39.203","J39.208","J39.209","J39.215","J39.219","J39.220","K09.205","K09.809","K11.605","K12.202","K12.206","Q18.001","Q18.002","Q35.300","Q35.903","T18.001","Z43.001"]
  adrg_zd1=[]
  adrg_ss=["28.0x00x002","28.0x02","28.0x03","29.0x00x006","29.2x00x001","29.3301","29.3900x001","29.3900x007","29.3900x010","29.3900x012","29.3900x019","29.3901","29.3905","29.3906","29.3908","29.3909","29.4x00x004","29.4x01","29.5200x002","30.0900x016","30.0900x021","30.0900x024","30.0900x039","30.0901","30.0902","30.0903","30.0904","30.0905","30.0906","30.0907","30.0909","30.0911","30.2100x002","30.2203","30.2900x003","30.2900x015","31.1x00x005","31.2900x001","31.5x04","31.6903","31.6911","31.7201","31.7300x001"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合DE1入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCD_DRG.DE11_group(record):
      return 'DE11'

    if MDCD_DRG.DE13_group(record):
      return 'DE13'

    if MDCD_DRG.DE15_group(record):
      return 'DE15'

    return 'DE1'
  else:
    return ''

